package com.wu.llpsw.yuanli.energy;

import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.capabilities.CapabilityManager;
import net.minecraftforge.common.capabilities.RegisterCapabilitiesEvent;
import net.minecraftforge.event.AttachCapabilitiesEvent;
import net.minecraftforge.eventbus.api.SubscribeEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.event.lifecycle.FMLCommonSetupEvent;
import javax.annotation.Nullable;
/**
 * 注册能力
 */
@Mod.EventBusSubscriber(modid = "wu")
public class CapabilityRegistryHandler {

    public static Capability<power> POWER;

    //将能力附加到玩家身上
    @SubscribeEvent
    public static void add(AttachCapabilitiesEvent<Entity> event){
        Entity entity = event.getObject();
        if (entity instanceof Player) {
            event.addCapability(new ResourceLocation("wu", "power"), new powerBody());
        }
    }


    //注册能力
    @SubscribeEvent
    public static void reg(RegisterCapabilitiesEvent event){
        event.register(powerBody.class);
    }
}
